package com.neuedu.javase.io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.io 
 * date:   2025/11/6   9:00  
 * 描述:  
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class MyWriter {

    public static void main(String[] args) {
        // 使用字符流
        String file = "d:\\upload\\introduce.txt";
        FileWriter writer = null;
        try {

            //public FileWriter(String fileName, boolean append)
            writer = new FileWriter(file,true);


            // public void write(int c)  char
            // writer.write((int)'你');
            // writer.write((int)'好');

        //     public void write(char cbuf[])
        //     char content[] = new char[]{',','大','家','好'};
        //     writer.write(content);

        //      public void write(String str)
            writer.write("\r\n今天星期四");




            // public void write(String str, int off, int len)

        //     public abstract void write(char cbuf[], int off, int len)



        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if(writer != null){
                try {
                    writer.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }


    }



}
